#include "../../include/types.h"
#include "../../include/memlayout.h"
#include "../../include/riscv.h"
#include "spinlock.h"
#include "proc.h"
#include "elf.h"
#include "../file/fs.h"
#include "../file/file.h"
#include "../file/log.h"
#include "../file/string.h"
#include "../mm/vm.h"

struct inode;

// map ELF permissions to PTE permission bits.
int flags2perm(int flags);

//
// the implementation of the exec() system call
//
int
kexec(char *path, char **argv);
// Load an ELF program segment into pagetable at virtual address va.
// va must be page-aligned
// and the pages from va to va+sz must already be mapped.
// Returns 0 on success, -1 on failure.
int
loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint32 offset, uint32 sz);
